﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EQual.MainModule.Reviews.DetailsViews
{
    /// <summary>
    /// This is The controler for Manipulating the participants to a review 
    /// This Uses An Employee List View  
    /// </summary>
    public class ReviewParticipantsPresenter : EQual .Infrastructure .MVPFramework .Presenters .ListPresenterBase <Employees .IEmployeesSelectionView ,object   >
    {
        public ReviewParticipantsPresenter()
        {
            View = new Employees.EmployeesSelectionView();
            View.ItemAdded += new EventHandler<Microsoft.Practices.Composite.Events.DataEventArgs<object>>(View_ItemAdded);
        }

        void View_ItemAdded(object sender, Microsoft.Practices.Composite.Events.DataEventArgs<object> e)
        {
              new DataAccesLayer.EQualDataLayerFactory().GetReviewsAccesLayer().AddNewParticipantToReview (ActiveItem, e.Value);
        }

        public override void Dispaly(object item)
        {
            View.Model = new
            {
                ItemsCollection = GetCollection(item)
            };
        }

        private System.Collections.IEnumerable GetCollection(object item)
        {
            return new DataAccesLayer.EQualDataLayerFactory().GetReviewsAccesLayer().GetParticipants(item);
        }

    }

}
